/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.appspot.nnaplanner;

import java.util.Date;


/**
 *
 * @author david
 */
public class Time {

    private int _hour;
    private int _minute;
    
    public Time(int hour, int minute) throws Exception {
        validate(hour, minute);
        _hour = hour;
        _minute = minute;
   
    }

    private void validate(int hour, int minute) throws Exception {
        if (hour < 0 || hour > 23) {
            throw new Exception("hour can only be from values 0 to 23");
        }

        if (minute < 0 || minute > 59) {
            throw new Exception("hour can only be from values 0 to 59");
        }
    }

    public Long getTime() {
        return getTime(_hour, _minute);
    }

    public Date getDate(Time t){
       return new Date(t.getTime());
    }

    public static Long getTime(int hour, int minute) {
        // 1 second = 1 000 milliseconds
        // 1 minute = 60 seconds = 60 000 milliseconds
        // 1 hour = 60 minutes = 3 600 seconds = 3 600 000 milliseconds
        long millisecs = 1000 * 60 * minute * hour;
        return millisecs;
    }

}
